/********************************************************************************
* File Name:	dlgdetail.cpp
* Description:	第十一章实例训练
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1
* E_mail: openlinux2011@gmail.com
********************************************************************************/
#include "dlgdetail.h"
#include "ui_dlgdetail.h"

#include <QAbstractItemView>
#include <QDebug>


DlgDetail::DlgDetail(int cid,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DlgDetail)
{
    ui->setupUi(this);
    this->cid=cid;

    model=new QSqlTableModel(this);
    this->model->setTable("orderlist");
    this->model->removeColumn(this->model->fieldIndex("cid"));
    this->model->setHeaderData(0,Qt::Horizontal,tr("编号"));
    this->model->setHeaderData(1,Qt::Horizontal,tr("菜名"));
    this->model->setHeaderData(2,Qt::Horizontal,tr("菜类型"));
    this->model->setHeaderData(3,Qt::Horizontal,tr("菜价格"));
    this->model->setHeaderData(4,Qt::Horizontal,tr("客户名称"));
    ui->tvDetail->setModel(model);
    ui->tvDetail->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //获取数据
    this->datainit();
}

void DlgDetail::datainit()
{
    qDebug()<<"cid :"<<cid;
    this->model->setFilter("cid="+QString::number(this->cid));
    this->model->select();
}
DlgDetail::~DlgDetail()
{
    delete ui;
}

void DlgDetail::on_pbOk_clicked()
{
    this->close();
}
